/** @file               sw_mqueue.h
 *  @copyright          Copyright (C) 2006-2026 flyfish (tenggui_fu@126.com)
 *  @brief              This file is part of the swallow library
 *  @author             $Author: flyfish $
 *  @version            $Rev: 385 $
 *  @date               $Date: 2016-12-22 00:12:05 +0800 (周四, 22 12月 2016) $
 */
#ifndef __SW_MQUEUE_H__
#define __SW_MQUEUE_H__

#include "mqueue.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef mqd_t SW_MQUEUE;
#define SW_INVALID_MQUEUE (SW_MQUEUE)(-1)

typedef enum _SW_MQUEUE_FLAG
{
    SW_MF_RDONLY,
    SW_MF_WRONLY,
    SW_MF_RDWR
}SW_MQUEUE_FLAG;

#define SW_MQUEUE_PRIO_MIN      0
#define SW_MQUEUE_PRIO_MAX      MQ_PRIO_MAX
#define SW_MQUEUE_PRIO_MID      ((SW_MQUEUE_PRIO_MIN + SW_MQUEUE_PRIO_MAX) / 2)

SW_API SW_RET SW_InitMQueueAPI(SW_VOID);
SW_API SW_RET SW_RunMQueueAPI(SW_VOID);
SW_API SW_RET SW_StopMQueueAPI(SW_VOID);
SW_API SW_RET SW_ExitMQueueAPI(SW_VOID);
SW_API SW_MQUEUE SW_OpenMQueue(const SW_CHAR *pName, SW_MQUEUE_FLAG flag, SW_BOOL nonBlock, SW_UINT32 msgMax, SW_UINT32 msgSize);
SW_API SW_RET SW_CloseMQueue(SW_MQUEUE mqd);
SW_API SW_RET SW_DeleteMQueue(const SW_CHAR *pName);
SW_API SW_RET SW_EnableMQueueNonBlock(SW_MQUEUE mqd, SW_BOOL enable);
SW_API SW_BOOL SW_IsMQueueNonBlockEnabled(SW_MQUEUE mqd);
SW_API SW_UINT32 SW_GetMQueueCurrentMsgCount(SW_MQUEUE mqd);
SW_API SW_RET SW_SendMQueue(SW_MQUEUE mqd, const SW_VOID *pMsg, SW_UINT32 msgLen, SW_UINT32 prio);
SW_API SW_UINT32 SW_RecvMQueue(SW_MQUEUE mqd, SW_VOID *pMsg, SW_UINT32 msgLen);
SW_API SW_RET SW_TimeSendMQueue(SW_MQUEUE mqd, const SW_VOID *pMsg, SW_UINT32 msgLen, SW_UINT32 prio, SW_UINT32 msec);
SW_API SW_UINT32 SW_TimeRecvMQueue(SW_MQUEUE mqd, SW_VOID *pMsg, SW_UINT32 msgLen, SW_UINT32 msec);
SW_API SW_UINT32 SW_GetMQueueMsgCount(SW_MQUEUE mqd);

#ifdef __cplusplus
}
#endif

#endif

